class Admin::DelayedJobsController < ApplicationController

  skip_before_filter :require_login
  before_filter :authenticate

  def index
    @delayed_jobs = Delayed::Job.all(:order => :id)
  end

  def destroy
    @delayed_job = Delayed::Job.find(params[:id])
    if @delayed_job.delete
      flash[:notice] = "Job deleted"
    end
    redirect_to admin_delayed_jobs_url
  end

  private

  def authenticate
    authenticate_or_request_with_http_basic do |username, password|
      username == APP_CONFIG["admin_username"] && password == APP_CONFIG["admin_password"]
    end
  end

end
